<?xml version="1.0" encoding="UTF-8"?>

<!--
    Document   : IndexStyleSheet.xsl
    Created on : November 21, 2013, 12:45 PM
    Author     : LeMinh
    Description:
        Purpose of transformation follows.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html"/>

    <!-- TODO customize transformation rules 
         syntax recommendation http://www.w3.org/TR/xslt 
    -->
    <xsl:param name="type" select="''"/>
    <xsl:template match="/">
        <xsl:if test="$type !=''" >
            <xsl:call-template name="menu"></xsl:call-template>
        </xsl:if>
        <xsl:if test="$type =''" >
            <xsl:call-template name="none-menu-dt"></xsl:call-template>
            <xsl:call-template name="none-menu-mt"></xsl:call-template>
        </xsl:if>
        
    </xsl:template>
 
    <xsl:template  name="none-menu-dt">
        
        <xsl:param name="list_dt" select="products/product[contains(type,'điện thoại')]"/>
        <xsl:for-each select="$list_dt[position()&lt; 17]" >

            <li>
                <div class="licontent">
                    <h3 style="color:#009">
                        <xsl:value-of select="name" />
                    </h3>
                    <xsl:variable name="img" select="imgLink"/>
                    <img src="{$img}" />

                    <h4 style="color:#F00">
                        Giá:
                        <xsl:value-of select="price" />
                    </h4>
                    <xsl:variable name="link" select="productLink"/>
                    <a href="{$link}">Xem chi tiết...</a>
                </div>
            </li>

        </xsl:for-each>
    </xsl:template>
    <xsl:template name="none-menu-mt">
       
        <xsl:param name="list_mt" select="products/product[contains(type,'máy tính')]"/>
        <xsl:for-each select="$list_mt[position()&lt; 17]" >

            <li>
                <div class="licontent">
                    <h3 style="color:#009">
                        <xsl:value-of select="name" />
                    </h3>
                    <xsl:variable name="img" select="imgLink"/>
                    <img src="{$img}" />

                    <h4 style="color:#F00">
                        Giá:
                        <xsl:value-of select="price" />
                    </h4>
                    <xsl:variable name="link" select="productLink"/>
                    <a href="{$link}">Xem chi tiết...</a>
                </div>
            </li>

        </xsl:for-each>
    </xsl:template>
    <xsl:template name="menu">
        <xsl:param name="list" select="products/product[contains(type,$type)]"/>
        <xsl:for-each select="$list" >

            <li>
                <div class="licontent">
                    <h3 style="color:#009">
                        <xsl:value-of select="name" />
                    </h3>
                    <xsl:variable name="img" select="imgLink"/>
                    <img src="{$img}" />

                    <h4 style="color:#F00">
                        Giá:
                        <xsl:value-of select="price" />
                    </h4>
                    <xsl:variable name="link" select="productLink"/>
                    <a href="{$link}">Xem chi tiết...</a>
                </div>
            </li>

        </xsl:for-each>

    </xsl:template>
</xsl:stylesheet>
